<?php

namespace app\admin\model;
use think\Model;

/**
 * 用户模型
 */

class Member extends Model {

    protected $insert = ['state'=>1];
    
    protected function setPasswordAttr()
    {
        $password = \think\Request::instance()->param('password');
        $authKey = \think\Config::get('uc_auth_key');
        return think_ucenter_md5($password, $authKey);
    }

    public function lists($state = 1, $order = 'uid DESC', $field = true){
        $map = array('state' => $state);
        return $this->field($field)->where($map)->order($order)->select();
    }

    public function getNickName($uid){
        return $this->where(array('uid'=>(int)$uid))->value('username');
    }

}
